package com.nbicc.survey.service.impl;

import com.nbicc.parent.serivce.BaseService;
import com.nbicc.survey.mapper.EssayQuestionTopicMapper;
import com.nbicc.survey.po.EssayQuestionTopic;
import com.nbicc.survey.service.IEssayQuestionTopicService;
import com.nbicc.utils.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;

@Service("EssayQuestionTopicServiceImpl")
public class EssayQuestionTopicServiceImpl extends BaseService implements IEssayQuestionTopicService {

    @Autowired
    private EssayQuestionTopicMapper essayQuestionTopicMapper;

    @Override
    public EssayQuestionTopic selectById(String id) {
        return essayQuestionTopicMapper.selectById(id);
    }


    @Override
    public Integer insert(EssayQuestionTopic essayQuestionTopic) {
        essayQuestionTopic.setId(ToolUtil.generateUUID32());
        essayQuestionTopic.setCreateTime(new Date());
        return essayQuestionTopicMapper.insert(essayQuestionTopic);
    }

    @Transactional
    @Override
    public Integer batchInsert(List<EssayQuestionTopic> essayQuestionTopicList) {
        for (EssayQuestionTopic essayQuestionTopic : essayQuestionTopicList) {
            insert(essayQuestionTopic);
        }
        return 1;
    }

    @Override
    public Integer updateById(EssayQuestionTopic essayQuestionTopic) {
        return essayQuestionTopicMapper.updateById(essayQuestionTopic);
    }

    @Override
    public Integer deleteById(String id) {
        return essayQuestionTopicMapper.deleteById(id);
    }

    @Override
    public List<EssayQuestionTopic> selectListByQuestionnaireId(String questionnaireId) {
        return essayQuestionTopicMapper.selectListByQuestionnaireId(questionnaireId);
    }

}
